package com.pointstar.dp.modules.project.controller;

import com.pointstar.dp.common.annotation.SysLog;
import com.pointstar.dp.common.entity.Page;
import com.pointstar.dp.common.entity.R;
import com.pointstar.dp.modules.project.entity.OutBoundDetailsEntity;
import com.pointstar.dp.modules.project.service.OutBoundDetailsService;
import com.pointstar.dp.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 出库明细表
 * @author Korey<m13057531285@163.com>
 */
@RestController
@RequestMapping("/outboundDetails")
public class OutBoundDetailsController extends AbstractController {
	
	private final OutBoundDetailsService outBoundDetailsService;

	@Autowired
	public OutBoundDetailsController(OutBoundDetailsService outBoundDetailsService) {
		this.outBoundDetailsService = outBoundDetailsService;
	}

	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@PostMapping("/list")
	public Page<OutBoundDetailsEntity> list(@RequestBody Map<String, Object> params) {
		return outBoundDetailsService.listOutBoundDetails(params);
	}

	/**
	 * 列表
	 * @return
	 */
	@PostMapping("/listNoPage")
	public List<OutBoundDetailsEntity> listNoPage(@RequestBody Map<String, Object> params) {
		return outBoundDetailsService.listOutBoundDetailsNoPage(params);
	}
		
	/**
	 * 新增
	 * @param outBoundDetails
	 * @return
	 */
	@SysLog("新增出库明细表")
	@PostMapping("/save")
	public R save(@RequestBody OutBoundDetailsEntity outBoundDetails) {
		return outBoundDetailsService.saveOutBoundDetails(outBoundDetails);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@PostMapping("/info")
	public R getById(@RequestBody Long id) {
		return outBoundDetailsService.getOutBoundDetailsById(id);
	}
	
	/**
	 * 修改
	 * @param outBoundDetails
	 * @return
	 */
	@SysLog("修改出库明细表")
	@PostMapping("/update")
	public R update(@RequestBody OutBoundDetailsEntity outBoundDetails) {
		return outBoundDetailsService.updateOutBoundDetails(outBoundDetails);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除出库明细表")
	@PostMapping("/remove")
	public R batchRemove(@RequestBody Long[] id) {
		return outBoundDetailsService.batchRemove(id);
	}
	
}
